<%@ page language="java" import="java.util.*,com.hs.auth.model.*,com.hs.core.utils.*" pageEncoding="utf-8"%>
<%
  HsAccount accObj = (HsAccount)request.getAttribute("accObj");
HsUserinfo userinfo = accObj==null?null:accObj.getUserinfo();
String flag = (String)request.getAttribute("flag");
List orgList = (List)request.getAttribute("orgList");
List roleList = (List)request.getAttribute("roleList");
String userrole = (String)request.getAttribute("userrole");

if(null == userrole||"null".equals(userrole)){
	userrole="";
}
String status = "";
if(null != accObj){
	status = String.valueOf(accObj.getStatus());
}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head>
<title>修改个人信息</title>
<%@ include file="../include.jsp"%>   

<script language="javascript" type="text/javascript" src="<%=path %>/thirtpart/My97DatePicker/WdatePicker.js"></script>

<style>.tac{text-align:center}</style>
 <script language="javascript" type="text/javascript">
 
 var flag = true;
 function callBackForCheckId(message){
 	  
 	    if("0" == message)
 	       alert("此帐号可以使用");
 	    else{
 	       alert("此帐号已存在，不可注册");  
 	    } 
 }
  function callBackForCheckId1(message){
 	  
 	    if("0" != message) {
 	       alert("此帐号已存在，不可注册"); 
 	       flag =false;
 	    } 
 }
 
 function checkUserId(){
 	 var logid = userform.loginid.value;
     if(isNull(logid)){
		        	alert("帐号不能为空!");
		            userform.loginid.focus();
		            return;
     }
     authdwr.isDouble(logid,callBackForCheckId);  
 
 }
 
 function saveData(){
           var logid = userform.loginid.value;
            var id = userform.id.value; 
             if(isNull(id)){
             	 if(isNull(logid)){
		        	alert("帐号不能为空!");
		            userform.loginid.focus();
		            return;
             	 }
              	 authdwr.isDouble(logid,callBackForCheckId1);   
             }
              setTimeout("checkform();",1000)
 }
 function checkform(){ 
    var logid = userform.loginid.value;
    var id = userform.id.value;
    var pwd = userform.pwd.value;
    var confirmpwd = userform.confirmpwd.value;
    var username = userform.username.value; 
    if(isNull(id)){
    	//新注册用户
       
        if(isNull(pwd)){
        	alert("密码不能为空!");
            userform.pwd.focus();
            return;
        }
        if(isNull(confirmpwd)){
        	alert("确认密码不能为空!");
            userform.confirmpwd.focus();
            return;
        }
        if( pwd != confirmpwd){
        	alert("密码与确认密码不一致!");
            userform.confirmpwd.focus();
            return;
        }
        if(isNull(username)){
        	alert("用户姓名不能为空！");
            userform.username.focus();
            return;
        }
    
    }else{
       if(isNull(username)){
        	alert("用户姓名不能为空！");
            userform.username.focus();
            return;
        } 
    }
    if(flag)
 	  userform.submit(); 
 }
 
 function closeWindow(){
 	window.close();
 }

 </script>
</head>
<body class="tac">
<div class="cont"> 
<form name="userform" action="<%=basePath %>auth/saveUserinfo.do" method="post">
     <table border="0" cellspacing="0" cellpadding="0" align=center width="99%" class="tableList">
      <caption ><font size="3">用户帐号信息(红色<font color=red>*</font>为必填项)</font></caption>
       
      <tr>
        <td width="15%">帐号</td>
        <td  colspan=3 nowrap><input type="text" name="loginid" value="<%=accObj==null?"":accObj.getLoginid() %>" style="width:95%" <%if(null != accObj){out.print(" disabled");} %>/><font color=red><strong>*</strong></font>
         <input type="hidden" name="id" value="<%=accObj==null?"":accObj.getId() %>"  />
         <input type="hidden" name="userid" value="<%=userinfo==null?"":userinfo.getId() %>"  />
         <input type="hidden" name="roleid" value="<%=userrole==null?"":userrole%>"  />
         <input type="hidden" name="status" value="<%=status %>"  />
        </td> 
      </tr>
       <tr>
        <td width="15%">密码</td>
        <td width="35%"><input type="password" name="pwd" value="" style="width:90%"></td>
        <td width="15%">确认密码</td>
        <td width="35%"><input type="password" name="confirmpwd" value="" style="width:90%"></td>
      </tr>
      <tr>
        <td width="15%">姓名</td>
        <td width="35%"><input type="text" name="username" value="<%=userinfo == null?"":userinfo.getUsername() %>" style="width:90%"><font color=red><strong>*</strong></font></td>
          <td width="15%">职称</td>
        <td width="35%">
       <%=DictCacheUtil.getInst().selectStrWithDefault("zhicheng","width:90%",userinfo==null?null:(userinfo.getZhicheng())+"","9") %>
       </td>  
      </tr>
       <tr>
        <td width="15%">出生年月</td>
        <td width="35%"><input type="text" class="Wdate" id="shengri" value="<%=userinfo == null?"":userinfo.getBirthday() ==null?"":userinfo.getBirthday()  %>"  style="width:90%" name="shengri"  onFocus="WdatePicker({el:'shengri',dateFmt:'yyyy-MM-dd'})"  /></td>
        <td width="15%">性别</td>
        <td width="35%"><input type="radio" value='1' name="sex" <%if("1".equals(userinfo == null?"":(userinfo.getUsersex()+""))){ out.print(" checked");} %>/>男
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" value='2' name="sex" <%if("2".equals(userinfo == null?"":(userinfo.getUsersex()+""))){ out.print(" checked");} %>/>女</td>
      </tr>
       <tr>
        <td width="15%">最高学历</td>
        <td width="35%"><%=DictCacheUtil.getInst().selectStrWithDefault("zuigxl","width:90%",userinfo==null?null:(userinfo.getZuigxl())+"","14") %></td>
        <td width="15%">毕业院校</td>
        <td width="35%"><input type="text" name="school" value="<%=userinfo == null?"":StringUtilTool.NULL2Blank(userinfo.getBiyeyx()) %>" style="width:90%"></td>
      </tr>
       <tr>
        <td width="15%">固定电话</td>
        <td width="35%"><input type="text" name="phone" value="<%=userinfo == null?"":StringUtilTool.NULL2Blank(userinfo.getPhone()) %>" style="width:90%"></td>
        <td width="15%">手机</td>
        <td width="35%"><input type="text" name="handphone" value="<%=userinfo == null?"":StringUtilTool.NULL2Blank(userinfo.getHandphone()) %>" style="width:90%"></td>
      </tr> 
       <tr>
        <td width="15%">通信地址</td>
        <td colspan=3><input type="text" name="postaddress" value="<%=userinfo == null?"":StringUtilTool.NULL2Blank(userinfo.getAddress()) %>" style="width:96%"></td> 
      </tr>
      <tr>
        <td width="15%">电子邮箱</td>
        <td  ><input type="text" name="email" value="<%=userinfo == null?"":StringUtilTool.NULL2Blank(userinfo.getEmail()) %>" style="width:90%"></td>
        <td width="15%">邮政编码</td>
        <td width="35%"><input type="text" name="postno" value="<%=userinfo == null?"":StringUtilTool.NULL2Blank(userinfo.getPostnum()) %>" style="width:90%"></td> 
      </tr>
      <tr>
        <td colspan=4 align="middle"> 
        	<input name="" type="button" value="保存" onclick="saveData();" class="btn btn-primary"/>
        	<input name="" type="button" value="关闭窗口" onclick="closeWindow();" class="btn btn-primary" />
        </td> 
      </tr> 
    </table>  
</form>
</div>
</body>
</html>
<script>
<%if(null!= flag){ %> 
    alert("保存成功！");
    window.close() 
<%}%>
</script>
